package cn.stylefeng.guns.modular.info.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;
import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * @program: guns-vip
 * @description: 比赛概况
 * @author: xiesm
 * @create: 2019-12-30 17:58
 **/
@TableName("t_cp_sg")
@Data
@Builder
public class CpSG implements Serializable {
    private static final long serialVersionUID = 1L;
    private Long id;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("date")
    private Date date;
    @TableField("num1")
    private Integer num1;
    @TableField("num2")
    private Integer num2;
    @TableField("num3")
    private Integer num3;
    @TableField("num4")
    private Integer num4;
    @TableField("num5")
    private Integer num5;
    @TableField("num6")
    private Integer num6;
    @TableField("num7")
    private Integer num7;
    @TableField("num8")
    private Integer num8;
    @TableField("num9")
    private Integer num9;
    @TableField("num10")
    private Integer num10;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField("create_time")
    private Date createTime;

    public List<Integer> getNums() {
        return Lists.newArrayList(num1, num2, num3, num4, num5, num6, num7, num8, num9, num10);
    }

    public Integer getNumIndex(Integer num) {
        List<Integer> nums = getNums();
        for (int i = 0; i < nums.size(); i++) {
            if (Objects.equals(num, nums.get(i))) {
                return i;
            }
        }
        return -1;
    }

    public Integer getNumFromIndex(Integer index) {
        List<Integer> nums = getNums();
        return nums.get(index);
    }
}
